package com.codetci.rabbitmq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: zhenzhong.wang@honeywell.com
 * @date: 2019/10/14 2:16 PM
 */
@Configuration
public class RabbitmqQueueConfig {

  @Bean
  public Queue queue1() {
    return new Queue("queue1");
  }
  @Bean
  public Queue queue2() {
    return new Queue("queue2");
  }
  @Bean
  public Queue queue3() {
    return new Queue("queue3");
  }

  @Bean
  public DirectExchange directExchange() {
    return new DirectExchange("directExchange");
  }
  @Bean
  public TopicExchange topicExchange() {
    return new TopicExchange("topicExchange");
  }
  @Bean
  public FanoutExchange fanoutExchange() {
    return new FanoutExchange("fanoutExchange");
  }

  @Bean
  public Binding bindingExchange1() {
    return BindingBuilder.bind(queue1()).to(directExchange()).with("test.queue1");
  }
  @Bean
  public Binding bindingExchange2() {
    return BindingBuilder.bind(queue2()).to(directExchange()).with("test.queue2");
  }
  @Bean
  public Binding bindingExchange3() {
    return BindingBuilder.bind(queue3()).to(directExchange()).with("queue3");
  }

  @Bean
  public Binding bindingExchange4() {
    return BindingBuilder.bind(queue1()).to(topicExchange()).with("test.*");
  }
  @Bean
  public Binding bindingExchange5() {
    return BindingBuilder.bind(queue2()).to(topicExchange()).with("test.*");
  }
  @Bean
  public Binding bindingExchange6() {
    return BindingBuilder.bind(queue3()).to(topicExchange()).with("queue3");
  }


  @Bean
  public Binding bindingExchange7() {
    return BindingBuilder.bind(queue1()).to(fanoutExchange());
  }
  @Bean
  public Binding bindingExchange8() {
    return BindingBuilder.bind(queue2()).to(fanoutExchange());
  }
  @Bean
  public Binding bindingExchange9() {
    return BindingBuilder.bind(queue3()).to(fanoutExchange());
  }
}
